'''
Created on Aug 14, 2009

@author: Roni
'''
import cliques.mdp.rtdp
import random
class LimitedSampling(cliques.mdp.rtdp.rtdp):
    '''
    classdocs
    '''

    def __init__(self, k, edge_prob, num_of_nodes):
        '''
        Constructor
        '''
        cliques.mdp.rtdp.rtdp.__init__(self, k, edge_prob, num_of_nodes)      
        
    def find_dfs_trial_value(self,state,action):
        original_value = state.g
        original_state = state
        value = state.g        

        while self.is_goal(state)==False and self.is_terminal(state)==False:
            state = self.generate_random_state(state,action)
            action = self.choose_heuristic_action(state)
            value=value+1
            if value-original_value>self.lookahead_depth:
                return state.pcdb.h+state.g
#        print "Solution Depth=%d" % (value-original_value)
        if self.is_terminal(state):
            return original_value+len(list(original_state.actions()))
        else:
            return value

    

    
